import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [{
		path: "/",
		redirect: '/home'
	},
	{
		path: "/home",
		name: "home",
		component: () =>
			import("@views/home.vue"),
		meta: {
			showTab: true
		}
	},
	{
		path: "/details",
		name: "details",
		component: () =>
			import("@views/details.vue")
	},
	{
		path: "/ceshi",
		name: "ceshi",
		component: () =>
			import("@views/ceshi.vue"),
		meta: {
			keepAlive:false,
			name:false
		}	
	},
	{
		path: "/user",
		name: "user",
		component: () =>
			import("@views/approval/index.vue"),
		children: [{
				path: "",
				redirect: 'approval'
			},
			{
				path: "approval",
				name: "approval",
				component: () =>
					import("@views/approval/approval.vue"),
				meta: {
					showTab: true,
					// keepAlive:true
					
				}	
			},
			{
				path: "waitapproval",
				name: "waitapproval",
				component: () =>
					import("@views/approval/waitApproval.vue"),
				meta: {
					showTab: true,
					// keepAlive:true
				}	
			}
		],
	},
	{
		path: "/approvalDetails",
		name: "approvalDetails",
		component: () =>
			import("@views/approval/approvalDetails.vue")
	},
	{
		path: "/approvalInput",
		name: "approvalInput",
		component: () =>
			import("@components/approvalInput.vue")
	},
	{
		path: "/addSubTable",
		name: "addSubTable",
		component: () =>
			import("@components/assemblys/addSubTable.vue")
	},
	{
		path: "/draft",
		name: "draft",
		component: () =>
			import("@views/apply/draft.vue")
	},
	{
		path: "/applyuser",
		name: "applyuser",
		component: () =>
			import("@views/apply/index.vue"),
		children: [{
				path: "",
				redirect: 'apply'
			},
			{
				path: "apply",
				name: "apply",
				component: () =>
					import("@views/apply/apply.vue"),
				meta: {
					showTab: true,
					// keepAlive:true
				}	
			},
			{
				path: "complete",
				name: "complete",
				component: () =>
					import("@views/apply/complete.vue"),
				meta: {
					showTab: true,
					// keepAlive:true
				}	
			}
		],
	}
];

const router = new VueRouter({
	mode: "hash",
	base: process.env.BASE_URL,
	routes
});
/**
 * 重写路由的push方法
 * 解决同一个路由路径重复点击报错
 */
const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
	return routerPush.call(this, location).catch(error => error);
};

export default router;
